<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
<title>记账--查询</title>
<script src="libs/jquery-1.12.1.min.js"></script>
  <link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
  <script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
  <script src="libs/handlebars.min.js"></script>
   <script src="libs/d3.v3.min.js"></script>
  <link href="libs/nv.d3.min.css" rel="stylesheet">
  <script src="libs/nv.d3.min.js"></script>
  <script src="libs/js.cookie-2.1.0.min.js"></script>
</head>
<body>
 <div class="container">
    <div class="row">
  <div class="page-header"><h2><strong>周三记账</strong></h2></div>
    </div>
</div>
<div class="container">
  <div class="row">
  <div class="col-md-12">
    <ul class="nav nav-pills">
    <li ><a href="index.html">首页</a></li>
    <li > <a href="in.html">新加收入</a></li>
    <li > <a href="out.html">新加支出</a></li>
    <li > <a href="chaxun.html"> 查询</a></li>
    <li class="active"> <a href="#"> 统计</a></li>
    <li > <a href="#">用户：<span id="text3"></span></a></li>
    <li> <a id="exit"> 退出</a></li>
    </ul>
  </div>
  </div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12"><hr/>
</div>
</div>
</div>
<div class="container">
<div class="row"><div class="col-md-6"><div class="panel panel-primary"><div class="panel-heading">当月收入总和</div><h2 align="center"  ><span id="text1" ></span></h2></div></div>

<div class="col-md-6"><div class="panel panel-primary"><div class="panel-heading">当月支出总和</div><h2 id="text2" align="center"></h2></div></div>
</div>
</div>
   <div class="container">
    <div class="row">
      <div class="col-md-6"  id="chart">
        <p class="text-center">
       <br/>
       <hr/>
       <strong>支出使用统计</strong>
       <svg style="height:480px;width:100%"></svg>
        <br/>
       </p>
      </div>
    
   <div class="col-md-6"  id="chart1">
       <p class="text-center">
       <br/>
       <hr/>
       <strong>收入使用统计</strong>
       <svg style="height:480px;width:100%"></svg>
       <br/>
      </div>
    </div>

     
    
</div>
<script id="template" type="text/x-handlebars-template">
{{#each item}}
<div class="panel panel-default col-md-3">
  <div class="panel-body">
   <dl>
     <dt>类别</dt> <dd>{{kind}}</dd>
     <dt>总和</dt> <dd>{{s1}}</dd>
     <dt>平均</dt> <dd>{{a1}}</dd>
    
   </dl>
 </div>
</div>
{{/each}}
</script>
<script type="text/javascript">
$(function(){
	
	$('#exit').click(function () {
	      $.post('exit.action', {
	        
	      }, function (res, status) {
	        if ('OK' == res) {
	          alert('退出成功'); window.location.href='login.html';
	        } else if ('ERR' == res) {
	          alert('账号或密码错误');
	          
	        }
	        
	      });
	    });
	
	
	
	  $.getJSON('querymonthin.action',function(res){
		$('#text1').text(res.s1);});
	  $.getJSON('querymonthout.action',function(res){
			$('#text2').text(res.s2);});
	  
	  $.getJSON('zongji.action',function(res){
		  console.log(res);
			nv.addGraph(function(){
				var chart=nv.models.pieChart()
				.x(function(d){
				return d.f1	
				}).y(function(d){
					return d.s1
				}).showLabels(true)
				.labelType('percent');
				d3.select("#chart svg")
				.datum(res)
				.transition().duration(350)
				.call(chart);
				return chart;
				});
			}); 
	  
	  
	
	  
	  
	  $.getJSON('zongji2.action',function(res){
		  console.log(res);
			nv.addGraph(function(){
				var chart1=nv.models.pieChart()
				.x(function(d){
				return d.f2	
				}).y(function(d){
					return d.s2
				}).showLabels(true)
				.labelType('percent');
				d3.select("#chart1 svg")
				.datum(res)
				.transition().duration(350)
				.call(chart1);
				return chart1;
				});
			}); 
	  $.getJSON('user.action',function(res){
			//console.log(res);  
		  $('#text3').text(res.nickname);
		  });
});
</script>
<script type="text/javascript">
if (!Cookies.get("user")){
	window.location.href='login.html';
}
</script>
</body>
</html>